package com.cssl.util;

import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.pagination.optimize.JsqlParserCountOptimize;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class IPageUtil {


    @Bean
    public PaginationInterceptor paginationInterceptor() {
        PaginationInterceptor page = new PaginationInterceptor();
        // 合理化
        // page.setOverflow(true);
        // 设置最大单页限制数量，默认 500 条，-1 不受限制
        // page.setLimit(500);
        page.setCountSqlParser(new JsqlParserCountOptimize(true));
        return page;
    }

    @Bean
    public PaginationInnerInterceptor pagination(){
        PaginationInnerInterceptor page = new PaginationInnerInterceptor();
        //page.setMaxLimit(500l);
        return page;
    }
}
